<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>入住登记</title>
</head>
<body>
    <h1>入住登记表</h1>
    <form id="registrationForm">
        <a for="name">姓名:</a>
        <input type="text" id="name" name="name" required><br><br>
        
        <a for="age">年龄:</a>
        <input type="text" id="age" name="age" required><br><br>
        
        <a for="address">家庭住址:</a>
        <input type="text" id="address" name="address" required><br><br>
        
        <a for="email">邮箱:</a>
        <input type="text" id="email" name="email" required><br><br>
        
        <a for="salary">工资:</a>
        <input type="text" id="salary" name="salary" required><br><br>
        <!-- 创建一个函数，在点击按钮时触发函数事件 -->
        <button type="button" onclick="sub()">提交</button>
    </form>

    <div id="text"></div>

    <script>
        function sub() {
          // 获取用户输入得值
            const name = document.getElementById('name').value;
            const age = document.getElementById('age').value;
            const address = document.getElementById('address').value;
            const email = document.getElementById('email').value;
            const salary = document.getElementById('salary').value;
            // 打印获取的值
            const output = ` 我叫${name}，我今年${age}岁，我住在${address}，我的邮箱是${email}，我的工资是${salary}元。 `;
            document.getElementById('text').innerHTML = output;
        }
    </script>
</body>
</html>